package com.book.bookshop.web;

import com.book.bookshop.entity.Adamin;
import com.book.bookshop.entity.User;
import com.book.bookshop.service.AdaminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpSession;

@Controller
@RequestMapping("/adamin")
public class AdaminController {
    @Autowired
    private AdaminService adaminService;

//    @ResponseBody//json
//    @RequestMapping("/checkName")
//    public String checkName(String adaminname){
//
//        return adaminService.loginCheck(adaminname);
//    }


    @ResponseBody
    @RequestMapping("/login")
    public String login(Adamin adamin, HttpSession session){

        return adaminService.loginCheck(adamin,session);

    }


    @RequestMapping("/logout")
    public String logout(HttpSession session){
        session.invalidate();
        return "redirect:/book/index";
    }

}
